An introduction to L.IN.OLEUM (Written By Heulanith )
Hello folks!
It's me, Heulanith! "Eh.. who?" you might be asking yourself. Don't worry - I'm a programmer who is active in the demoscene. Up to now, I have only released really bad produtions. You wouldn't even want to see them, as you will be contemplating to commit suicide or something even worse after viewing them. In doing this, it will bring a great shame to the demoscene in general, and it is something we really don't want to see happen, right?
Before we proceed to the next topic, please remember that this is my first article ever published!
What is "Linoleum" all about?
If you read so far, you most properly will want to know what it is :D
Linoleum is a low-level programming language created by Alessandro Ghignola, Home Sweet Pixel Software (www.anywherebb.com). Please go to the Website. Now locate the l.in.oleum link and download the file. Unzip it, then install it. Remember to read the docs and take a look at the examples. Then you can write your very own good looking, and fast programs that have an amazing GUI. Of course you will need the ability to learn how to design a program with a very nice GUI. Following are some examples in how to create such a program.
You can make your own icons for your Linoleum programs (they don't work for "normal" programs).
You can also create 3D-Models/Sceneries with the editor. The editor actually does SOFTWARE rendering! It's cute, and beautiful!
How I got involved
It was a day, around 1.2 years ago, when I was surfing on the internet viewing a site that I visit every day, gamehippo, to see if there was any new freeware games to play. I had the luck to find one. The game was called "Noctis IV". I was reading the description of the game, then i noticed these lines:
"Noctis is simply huge. There are about 70 billion stars, and you can go to every single one of them. Each one of the stars can have up to 30 planets, and each planet can have moons. When visting a planet or a moon, you also have the option of landing on it."
I couldn't believe my eyes! The game was only about 1.5 Mb in size! I immediately downloaded it, unzipped it and then started to play it. The game has a very strange control scheme, thus I needed to read the instructions to learn the controls, and how to figure out all of the menus. When I reached my first star, it didn't have a real name. The only text that appeared in the upper left corner of the screen was "Unknown Star". I chose a planet that was circling the star. I picked a pixel on the planet's surface, so I could land my ship on to it. WOW! What an amazingly big world! I had my reservations about all of the random surfaces. "How could it be so big?". I intended to do some research - I left the planet and the star system to find another one, and landed on it.
I waited for a whole day and then played the game again to see if the surface was really random. When I arrived at the first star that I had discovered the previous day, I made a surprising discovery: the same Planet had the the same textures. I wondered "WTF!?", the game universe wasn't totally random at all, there were some very small pieces of the surface that were random but not everything. "Amazing", I thought and then visited the author's website. I took a look at the forum on the author's site.
I found a lot of interesting information there. I eventually found a link that read "l.in.oleum" and wondered: "Hmm... what could this be...? I'll check it out." I did, in doing so, read the following text; which made me download it immediately. (I'm in love with fast programs!)
"This language has an almost 1:1 source-to-CPU instruction ratio, allows direct access to five general-purpose registers (performing basic operations from a theoretical 2 up to a practical of even 10 times faster than memory-held variables), and if used well, is averagely twice as fast as C in pure computational power."
You read it? Good, then you know one of the reasons why I choose to programme in Linoleum. Saying that, I also programme in C - but that is almost only when I'm writing a demo or intro.
Advantages / Disadvantages
Hmm... How does Linoleum compare to C?
Firstly, Linoleum programs are a lot faster than C programs, but C is a lot easier to navigate through (i.e. it's easier to locate functions in C).
But what about GUI work? In C you have to do a lot of work to get a good looking GUI that works fine (and ends up being rather slow). In Linoleum you only have to... nah, it's that simple. In addition, there's a default GUI style which can be modified very easily.
Because Linoleum is a low-level language, you can't write an expression like:
pos = ((y*windowWidth) + x);
Instead you have to do each of these instructions individually, BY HAND!
For Example:
pos=y; pos*windowWidth; pos+x;
OR
pos=y; pos*windowWidth; pos+x;
The Basics
In this part of the article, I'll quickly show you the very basics of Linoleum programming language. For the more advanced topics, you have to discover them yourself by UNDERSTANDING the examples.
So we begin with a very, very, very basic program:
(Notice: "(" starts a comment and ")" will close it)
"directors" program name = { BASICS_OF_GRAPHICS }; unit = 32; "constants" "workspace" Primary Display = 320 mtp 240; (size of window, 320x240) "programme" [Display Origin] = Primary Display; (set display origin to primary display) A = 12; B = 34; C = FF0000h; B * [Display Width]; (linear_pos = y_position * display_width) B + A; (linear_pos += x_position) B + [Display Origin]; (linear_pos += display_origin) [B] = C; (*linear_pos = color OR displaybuf[linear_pos] = color) [Display Command] = RETRACE; (Set display command) isocall; (Do command) "wait keystroke" [Console Command] = GET CONSOLE INPUT; (Set console command) isocall; (Do command) ? failed -> wait keystroke; (input failed? if so, try again) end; (end of program)
So, what the hell does this programme do?
First I'll explain the "directors" section. In this little program, I only defined the name of the application and the unit value. In this case it is 32, which means 32 bit.
Next is the "constants" section. This is where you can define your constants, for example:
CONSTANT_NAME = 20;
This would define CONSTANT_NAME to 20, so the next time you're writing CONSTANT_NAME in your source file the compiler will move it and insert an "20" in it's place.
What is this "workspace"?
That's where you define your workspace. One of the most very basic constants in your workspace is the window width and the height. In the example above, I decided to make it 320x240, so don't think that it's the only resolution available!
Then there is the last section: "programme". This is where the main programme code goes. It is exactly what I'm going to explain below.
First we see:
[Display Origin] = Primary Display;
This one just sets the.. Ah, you see it on the code!!
What about these lines?
A = 12; B = 34; C = FF0000h;
Here we are going to use three of the five general-purpose registers. We don't have to use D and E in this programme, so we'll just leave them unused. As to what actually is happening here, you can easily read it from the code. It's so easy to understand.
Here's the code that calculates the pixel position:
B * [Display Width]; B + A; B + [Display Origin]; [B] = C;
Do you understand this code? (Look at the comments in the code above to see that piece of code mirrored to C code.)
The only important line is the following one:
[B] = C;
You may be thinking: "What, you just set the value of B to C?". Well actually not; here we're setting the value of the address of B to C, and then B is pointing to a position in the display buffer, in turn that it will make us plot a pixel on to the screen.
So in summary, "[register_1] = register_2" sets the value of the address of register_1 to register_2.
The next two lines have good comments, and I'm sure you will understand them easily as well.
You will come across a "wait keystroke" command next. Is that pointing to another section? No, this is how you define labels and functions. Then we have two easy to understand lines next (just read the comments). Then comes the next line. What the hell is this? In Linoleum, you don't write "if(_CONDITIONS_){ _DO_SOMETHING_ }", you just write an "if" as "?". This line means "if failed, then jump to 'wait keystroke'".
Are you smart enough to figure out what the last line does?
What I haven't told you
Here's a short (very short) list of topics you could read about in the readme to learn:
1: Variables, how to create and use them.
2: How to include libraries.
3: How to mark the end of a function, and how to use a FUNCTION, as "->" only means "jump to label" and "=>" means "call label".
4: There is a stockfile section, so best to read about it.
5: Finally, how do you make that beautiful GUI I talked about earlier? In order to learn about this, just browse the examples and run them. It's the best way to learn!
Closing words
What to say?
This is my first article ever and I hope you enjoyed it!
Anyway, thanks for reading it (if you did)!